package rohyunji;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class CompanySVC extends JPanel{
	private JTextField textField;
	private JTextField textField_1;
	private JComboBox comboBox_1;
	private String mb_no;
	private String cp_no;
	private CompanyVO cv;
	private CompanyDAO cdao;
	public CompanySVC
	(String mb_number,final CardLayout menu2AreaCard, final JPanel menuArea2,final CardLayout rightCard,final JPanel right_area) {
		
		

		
		mb_no="100";
		cv=new CompanyVO();
		
		cv.setMb_no(mb_no);
		cdao=new CompanyDAO();
		for(CompanyVO cv2:cdao.selectCp_no(cv))
		{
			cp_no=cv2.getCp_no();
			
		}
		
		JButton lbtn = new JButton("확인");
		add(lbtn);
		JButton lbtn2 = new JButton("기업정보등록");
		add(lbtn2);
		JButton lbtn3 = new JButton("기업조회");
		add(lbtn3);
		
		lbtn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			
			//로그아웃 처리시 다시 로그인전으로 되돌림
				rightCard.show(right_area, "rightcard2");
				
				menu2AreaCard.show(menuArea2, "menuP");
				
			}});
		
		//기업정보등록 클릭시
		lbtn2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
	
//			if(cp_no!=null)
//				{
//					JOptionPane.showMessageDialog(null, "기업정보 이미 입력하셨습니다.");
//				}
//				else
//				{
				JPanel cp_create=new CreateCompany(mb_no,menu2AreaCard,menuArea2,rightCard,right_area);
				
				right_area.add(cp_create,"cp_create");
				rightCard.show(right_area,"cp_create");
//		}
			}});
		
		
		//기업정보조회를클릭했을때 내용 영역에 조회내용이 출력됨 
		lbtn3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				

				JPanel cp_read=new ReadCompany(cp_no,menu2AreaCard,menuArea2,rightCard,right_area);
				
				right_area.add(cp_read,"cp_read");
				rightCard.show(right_area,"cp_read");
				
				
				
		
			}});
		
	}

	
}
